﻿Public Class F1_Doi_Mat_Khau

    Private Sub btnyes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnyes.Click

        Dim tendn As String = tbxten.Text
        Dim matkhaucu As String = txtmkcu.Text
        Dim mk1 As String = txtmatkhau.Text
        Dim mk2 As String = tbxmk2.Text
        Dim mand As Integer = 0

        If (tendn = "" Or matkhaucu = "" Or mk1 = "" Or mk2 = "") Then
            MessageBox.Show("Chua nhap du thong tin!", "Chu y!")
        ElseIf (mk1 <> mk2) Then
            MessageBox.Show("Mat khau moi va mat khau nhap lai khong dung!", "Chu y!")
        Else
            Dim kq As Integer
            If matkhaucu = "0" Then
                kq = XL_NguoiDung.KiemTraDangNhap(tendn, matkhaucu, mand)
            Else
                kq = XL_NguoiDung.KiemTraDangNhap(tendn, XL_NguoiDung.MD5(matkhaucu), mand)
            End If

            If kq <> 0 Then
                Dim dmk As Boolean = XL_NguoiDung.DoiMatKhau(tendn, XL_NguoiDung.MD5(mk1))
                Me.Close()
            Else
                MessageBox.Show("username hoac password cu khong dung!" + matkhaucu, "Chu y!")
            End If
        End If
    End Sub

    Private Sub btnthoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnthoat.Click
        Me.Close()
    End Sub
End Class